[Unit]
Description=Atomic OpenShift Master API
Documentation=https://github.com/openshift/origin
After=etcd_container.service
Wants=etcd_container.service
Before={{ openshift_service_type }}-node.service
After={{ openshift_docker_service_name }}.service
After=chronyd.service
After=ntpd.service
PartOf={{ openshift_docker_service_name }}.service
Requires={{ openshift_docker_service_name }}.service

[Service]
EnvironmentFile=/etc/sysconfig/{{ openshift_service_type }}-master-api
Environment=GOTRACEBACK=crash
ExecStartPre=-/usr/bin/docker rm -f {{ openshift_service_type}}-master-api
ExecStart=/usr/bin/docker run --rm --privileged --net=host \
  --name {{ openshift_service_type }}-master-api \
  --env-file=/etc/sysconfig/{{ openshift_service_type }}-master-api \
  -v {{ r_openshift_master_data_dir }}:{{ r_openshift_master_data_dir }} \
  -v /var/log:/var/log -v /var/run/docker.sock:/var/run/docker.sock \
  -v {{ openshift.common.config_base }}:{{ openshift.common.config_base }} \
  {% if openshift_cloudprovider_kind | default('') != '' -%} -v {{ openshift.common.config_base }}/cloudprovider:{{ openshift.common.config_base}}/cloudprovider {% endif -%} \
  -v /etc/pki:/etc/pki:ro \
  {% if l_bind_docker_reg_auth | default(False) %} -v {{ oreg_auth_credentials_path }}:/root/.docker:ro{% endif %}\
  {{ osm_image }}:${IMAGE_VERSION} start master api \
  --config=${CONFIG_FILE} $OPTIONS
ExecStartPost=/usr/bin/sleep 10
ExecStop=/usr/bin/docker stop {{ openshift_service_type }}-master-api
LimitNOFILE=131072
LimitCORE=infinity
WorkingDirectory={{ r_openshift_master_data_dir }}
SyslogIdentifier={{ openshift_service_type }}-master-api
Restart=always
RestartSec=5s

[Install]
WantedBy={{ openshift_docker_service_name }}.service
WantedBy={{ openshift_service_type }}-node.service
